﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AncientLand.Service.Entity;
using AncientLand.Service.IBiz;
using AncientLand.Service.IDa;

namespace AncientLand.Biz
{
   public class PhotosBiz:IPhotosBiz
    {
        private readonly IPhotosRepository _repository;
        private readonly ICommit _commitAble;
        public PhotosBiz(IPhotosRepository repository, ICommit commitAable)
        {
            this._repository = repository;
            this._commitAble = commitAable;
        }  
       public IEnumerable<Photos> GetAll()
       {
           return _repository.GetAll();
       }

       public Photos GetById(int id)
       {
           return _repository.GetById(id);
       }

       public void Create(Photos item)
       {
           _repository.Add(item);
           Save();
       }

       public void Update(Photos item)
       {
           _repository.Update(item);
           Save();
       }

       public void Delete(int id)
       {
           var news = _repository.GetById(id);
           _repository.Delete(news);
           Save();
       }

       public void Save()
       {
           _commitAble.Commit();
       }

       public IEnumerable<WeddingPhoto> GetWeddingPhotoByPages(out int totalRecord, int? pageIndex, int? pageSize, string orderFiled)
       {
           return _repository.GetWeddingPhotosByPages(pageIndex.GetValueOrDefault(), pageSize.GetValueOrDefault(), orderFiled, out totalRecord);
       }

       public IEnumerable<PictorialPhoto> GetPictorialPhotoByPages(out int totalRecord, int? pageIndex, int? pageSize, string orderFiled)
       {
           return _repository.GetPictorialPhotoByPages(pageIndex.GetValueOrDefault(), pageSize.GetValueOrDefault(), orderFiled, out totalRecord);
       }

       public IEnumerable<Photos> GetItemsByPagesForHomePage(out int totalRecord, int? pageIndex, int? pageSize)
       {
           return _repository.GetItemsByPagesForHomePage(out totalRecord,pageIndex.GetValueOrDefault(), pageSize.GetValueOrDefault());
       }
       public IEnumerable<Photos> GetItemsByPagesForHomePage( int? pageIndex, int? pageSize)
       {
           return _repository.GetItemsByPagesForHomePage(pageIndex.GetValueOrDefault(), pageSize.GetValueOrDefault());
       }
    }
}
